package com.yl.chainStore.entity.pay

import com.baomidou.mybatisplus.annotation.IdType
import com.baomidou.mybatisplus.annotation.TableField
import com.baomidou.mybatisplus.annotation.TableId
import com.baomidou.mybatisplus.annotation.TableName
import com.yl.chainStore.common.Constants
import com.yl.chainStore.common.enums.TypeEnum
import com.yl.common.annotation.NoArg
import java.math.BigDecimal
import java.math.RoundingMode

/**
 * <p>
 *
 * </p>
 *
 * @author cxw
 * @since 2021-11-21
 */
@NoArg
@TableName("pay_order_customer_pay_log_detail")
data class PayOrderCustomerPayLogDetail(

	/**
	 * id
	 */
	@TableId(value = "id", type = IdType.AUTO)
	var id: Long,

	/**
	 * 付款记录id
	 */
	@TableField("pay_log_id")
	var payLogId: Long = 0,

	/**
	 * 付款类型
	 */
	@TableField("pay_type")
	var payType: TypeEnum,

	/**
	 * 付款金额
	 */
	@TableField("pay_money")
	var payMoney: Long = 0,

	){
	/**
	 * 金额显示
	 */
	@TableField(exist = false)
	var moneyShow: BigDecimal?= null
		get() {

			if(field == null){
				return BigDecimal(payMoney.div(Constants.OtherConfig.MONEY_TO_DB_DOUBLE)).setScale(2, RoundingMode.HALF_UP)
			}
			return field
		}
		set(value) {
			if(value != null){
				payMoney = (value.multiply(BigDecimal(Constants.OtherConfig.MONEY_TO_DB_DOUBLE))).toLong()
				field = value
			}
		}
}
